package org.huangrui.spark.java.core.rdd.operate;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import java.util.Arrays;
import java.util.List;

/**
 * 分区内有序，分区间无序
 * @Author hr
 * @Create 2024-10-16 19:33
 */
public class Spark02_Operate_Transform_Map_4 {
    public static void main(String[] args) {
        SparkConf conf = new SparkConf().setMaster("local[*]").setAppName("spark");
        JavaSparkContext jsc = new JavaSparkContext(conf);

        final List<Integer> nums = Arrays.asList(1, 2, 3, 4);

        final JavaRDD<Integer> rdd = jsc.parallelize(nums, 2);
        JavaRDD<Integer> newRdd = rdd.map(num -> {
            System.out.println("num = " + num);
            return num * 2;
        });

        newRdd.collect();
        jsc.close();
    }
}
